package com.nbsaas.boot.order.rest.convert;

import com.nbsaas.boot.order.data.entity.Order;
import com.nbsaas.boot.order.api.domain.simple.OrderSimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* 列表对象转换器
*/

public class OrderSimpleConvert implements Converter<OrderSimple, Order> {




@Override
public OrderSimple convert(Order source) {
    OrderSimple result = new OrderSimple();

                result.setOrderType(source.getOrderType());
                if(source.getCatalog()!=null){
                   Map<Integer,String> CatalogMap=new HashMap<>();
                       CatalogMap.put(1,"普通订单");
                       CatalogMap.put(2,"团购订单");
                       CatalogMap.put(3,"秒杀订单");
                   String label=  CatalogMap.get(source.getCatalog());
                   result.setCatalogName(label);
                }
                result.setCatalog(source.getCatalog());
                result.setNum(source.getNum());
                result.setVerificationTime(source.getVerificationTime());
                result.setOrderStatus(source.getOrderStatus());
                result.setMerchantDiscount(source.getMerchantDiscount());
                result.setPaymentAmount(source.getPaymentAmount());
                result.setProgressPayment(source.getProgressPayment());
                result.setDeliveryAddressId(source.getDeliveryAddressId());
                result.setFirstPaymentRatio(source.getFirstPaymentRatio());
                result.setVoucherDeduction(source.getVoucherDeduction());
                result.setFirstPayment(source.getFirstPayment());
                result.setOrderTime(source.getOrderTime());
                result.setMerchantId(source.getMerchantId());
                result.setDeliveryAddress(source.getDeliveryAddress());
                result.setFinalPayment(source.getFinalPayment());
                result.setCustomerId(source.getCustomerId());
                if(source.getState()!=null){
                   Map<Integer,String> StateMap=new HashMap<>();
                       StateMap.put(1,"待支付");
                       StateMap.put(2,"待发货");
                       StateMap.put(3,"待收货");
                       StateMap.put(4,"待评价");
                       StateMap.put(5,"已完成");
                       StateMap.put(6,"已取消");
                   String label=  StateMap.get(source.getState());
                   result.setStateName(label);
                }
                result.setState(source.getState());
                result.setShippingTime(source.getShippingTime());
                result.setId(source.getId());
                result.setPaymentTime(source.getPaymentTime());
                result.setPointsDeduction(source.getPointsDeduction());
                result.setPaymentStatus(source.getPaymentStatus());
                result.setLastDate(source.getLastDate());
                result.setOrderSource(source.getOrderSource());
                result.setAmount(source.getAmount());
                result.setPlatformDiscount(source.getPlatformDiscount());
                result.setOrderNo(source.getOrderNo());
                if(source.getSourceClient()!=null){
                   Map<Integer,String> SourceClientMap=new HashMap<>();
                       SourceClientMap.put(1,"微信");
                       SourceClientMap.put(2,"支付宝");
                       SourceClientMap.put(3,"银联");
                       SourceClientMap.put(4,"快捷支付");
                       SourceClientMap.put(5,"微信公众号");
                       SourceClientMap.put(6,"微信小程序");
                   String label=  SourceClientMap.get(source.getSourceClient());
                   result.setSourceClientName(label);
                }
                result.setSourceClient(source.getSourceClient());
                result.setVerificationStatus(source.getVerificationStatus());
                result.setOrderCompletionTime(source.getOrderCompletionTime());
                result.setReferrerId(source.getReferrerId());
                result.setStoreId(source.getStoreId());
                result.setAddDate(source.getAddDate());
                result.setVerificationCode(source.getVerificationCode());
                result.setActualPaymentAmount(source.getActualPaymentAmount());
                result.setPaymentNotes(source.getPaymentNotes());
                result.setShippingNo(source.getShippingNo());
                result.setOrderNotes(source.getOrderNotes());
                result.setPaymentMethod(source.getPaymentMethod());
                result.setTotalDiscount(source.getTotalDiscount());
                result.setPaymentAccount(source.getPaymentAccount());


    return result;
}

}